#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005], better;

void dfs(int pos, int n){
    if(b[1]==2)
        return;
    if(pos==n+1){
        int cnt = 0;
        for(int i=1;i<=n;i++){
            int pc = 0;
            for(int j=i-1;j>=1;j--){
                if(b[j]==b[i]){
                    pc = j;
                    break;
                }
            }
            if(a[i]==a[pc])
                cnt += a[pc];
        }
        better = max(better, cnt);
        return;
    }
    b[pos] = 1;
    dfs(pos+1, n);
    b[pos] = 2;
    dfs(pos+1, n);
}
int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int t;
    cin >> t;
    while(t--){
        better = 0;
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        int n;
        cin >> n;
        for(int i=1;i<=n;i++)
            cin >> a[i];

        dfs(0, n);
        cout << better << endl;
    }
    return 0;
}
